import sys
from PyQt5.QtWidgets import QApplication
from user_interface import UserInterface
from database_connection import DatabaseConnection
from password_generator import PasswordGenerator
from config_file_handler import ConfigFileHandler
from service_manager import ServiceManager

class MainApp:
    def __init__(self):
        self.app = QApplication(sys.argv)
        self.ui = UserInterface()
        self.db_conn = DatabaseConnection(server="localhost", database="master", username="sa")
        self.pw_gen = PasswordGenerator()
        self.config_handler = ConfigFileHandler(file_paths=["配置文件模板\config1.ini", "配置文件模板\config2.yaml"])
        self.service_mgr = ServiceManager()
        
        # 连接UI信号与槽函数
        self.ui.setup_connections(
            self.db_conn,
            self.pw_gen,
            self.config_handler,
            self.service_mgr
        )
        
    def run(self):
        self.ui.show()
        sys.exit(self.app.exec_())

if __name__ == "__main__":
    main_app = MainApp()
    main_app.run()